const { ccclass, property } = cc._decorator;
import baseManager from '../../../base/baseManager';

@ccclass
export default class eventManager extends baseManager {

    private events: Map<string, cc.EventTarget> = new Map();

    clear() {
        return this.events.clear();
    }

    delete(rootName: string) {
        return this.events.delete(rootName);
    }

    get(rootName: string): cc.EventTarget {
        if (typeof rootName === 'undefined') {
            return null;
        }
        if (this.events.has(rootName)) {
            return this.events.get(rootName)
        }

        const event = new cc.EventTarget();
        this.events.set(rootName, event);
        
        return event;
    }
}
